home *** CD-ROM | disk | FTP | other *** search
/ The Trig Explorer / The Trig Explorer.iso / pc / explorer / function.dxr / 00093.ls < prev    next >
Encoding:
Text File  |  1997-07-22  |  3.4 KB  |  103 lines

  1. on mouseDown me
  2.   set xCenter to ((the left of sprite 4 + the right of sprite 4) / 2) + 1
  3.   set yCenter to ((the top of sprite 4 + the bottom of sprite 4) / 2) + 2
  4.   set radius to the width of sprite 4 / 2
  5.   set the cursor of sprite the spriteNum of me to [member "Closed hand", member "Closed Hand Mask"]
  6.   repeat while the stillDown
  7.     set mx to the mouseH
  8.     set my to the mouseV
  9.     set xAtMouse to mx - xCenter
  10.     set yAtMouse to my - yCenter
  11.     if xAtMouse <> 0 then
  12.       set angleAtMouse to atan(float(abs(yAtMouse)) / float(abs(xAtMouse)))
  13.       if angleAtMouse = 0 then
  14.         set yAtCircle to 0
  15.         set xAtCircle to radius * (xAtMouse / abs(xAtMouse))
  16.       else
  17.         set yAtCircle to sin(angleAtMouse) * float(radius) * (yAtMouse / abs(yAtMouse))
  18.         set xAtCircle to cos(angleAtMouse) * float(radius) * (xAtMouse / abs(xAtMouse))
  19.       end if
  20.     else
  21.       set xAtCircle to 0
  22.       if yAtMouse <> 0 then
  23.         set yAtCircle to radius * (yAtMouse / abs(yAtMouse))
  24.       else
  25.         set yAtCircle to radius
  26.       end if
  27.     end if
  28.     set the locH of sprite the clickOn to xCenter + xAtCircle
  29.     set the locV of sprite the clickOn to yCenter + yAtCircle
  30.     drawLine(6, yCenter, xCenter, the locV of sprite the clickOn, the locH of sprite the clickOn)
  31.     set the locH of sprite 5 to ((the left of sprite 6 + the right of sprite 6) / 2) + 10
  32.     set the locV of sprite 5 to ((the top of sprite 6 + the bottom of sprite 6) / 2) - 20
  33.     drawLine(7, the locV of sprite the clickOn, the locH of sprite the clickOn, yCenter, the locH of sprite the clickOn + 2)
  34.     set dy to float(yCenter - the locV of sprite the clickOn)
  35.     set dy to -dy
  36.     set dx to float(xCenter - the locH of sprite the clickOn)
  37.     if dx = 0 then
  38.       if dy < 0 then
  39.         set theta1 to float(1.5 * PI)
  40.       else
  41.         set theta1 to float(PI / 2.0)
  42.       end if
  43.     else
  44.       if dx > 0 then
  45.         set theta1 to float(atan(float(dy / dx)))
  46.         if theta1 < 0 then
  47.           set theta1 to float(theta1) + (2.0 * PI)
  48.         end if
  49.       else
  50.         set theta1 to float(atan(float(dy / dx))) + PI
  51.       end if
  52.     end if
  53.     set the floatPrecision to 2
  54.     if theta1 > PI then
  55.       set theta1 to theta1 - PI
  56.     else
  57.       set theta1 to theta1 + PI
  58.     end if
  59.     set temp to theta1 * 180.0 / PI
  60.     if dy <> 0 then
  61.       put temp into field "theta"
  62.     else
  63.       if dx < 0 then
  64.         put "0.0" into field "theta"
  65.       else
  66.         put "180.0" into field "theta"
  67.       end if
  68.     end if
  69.     set theta2 to field "theta"
  70.     if (theta2 = 90) or (theta2 = 270) then
  71.       put "90.0" into field "thetaR"
  72.     else
  73.       if theta2 < 90 then
  74.         put field "theta" into field "thetaR"
  75.       end if
  76.       if (theta2 > 90) and (theta2 < 180) then
  77.         put 180 - theta2 into field "thetaR"
  78.       end if
  79.       if (theta2 > 180) and (theta2 < 270) then
  80.         put theta2 - 180 into field "thetaR"
  81.       end if
  82.       if (theta2 > 270) and (theta2 < 360) then
  83.         put 360 - theta2 into field "thetaR"
  84.       end if
  85.     end if
  86.     if field "theta" = "180.0" then
  87.       put "0.0" into field "ThetaR"
  88.     end if
  89.     updateStage()
  90.   end repeat
  91.   set the cursor of sprite the spriteNum of me to [member "hand", member "Hand Mask"]
  92. end
  93.  
  94. on beginSprite me
  95.   set the cursor of sprite the spriteNum of me to [member "hand", member "Hand Mask"]
  96.   put "19.2" into field "theta"
  97.   put "19.2" into field "thetaR"
  98. end
  99.  
  100. on endSprite me
  101.   set the cursor of sprite the spriteNum of me to 0
  102. end
  103.